// Copyright (c)  YISH. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System.Collections.Generic;

namespace NSQL.Sharpen
{
    internal static class DictionaryExtensions
    {
        public static void AddOrReplace<TKey, TValue>(this IDictionary<TKey, TValue> self, TKey key, TValue value)
        {
            lock (self)
            {
                if (self.ContainsKey(key))
                {
                    self[key] = value;
                }
                else
                {
                    self.Add(key, value);
                }
            }
        }
    }
}